package flc.ast.adapter;

import android.view.View;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ConvertUtils;
import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import java.text.SimpleDateFormat;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.basic.media.bean.AudioBean;

public class SelAudioAdapter extends StkProviderMultiAdapter<AudioBean> {

    public SelAudioAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(82));
        addItemProvider(new SelAudioProvider());
    }

    private boolean isEdit = true;

    public void setEdit(boolean edit) {
        isEdit = edit;
    }

    private class SelAudioProvider extends BaseItemProvider<AudioBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_sel_audio;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, AudioBean bean) {
            baseViewHolder.setText(R.id.tvSelAudioItemName, bean.getName());
            baseViewHolder.setText(R.id.tvSelAudioItemSize, ConvertUtils.byte2FitMemorySize(bean.getSize(), 0));
            if (bean.isSelected()) {
                baseViewHolder.setImageResource(R.id.ivSelAudioItemSel, R.drawable.axuanzhong);
            } else {
                baseViewHolder.setImageResource(R.id.ivSelAudioItemSel, R.drawable.aweixuanzhong2);
            }
            if (isEdit) {
                baseViewHolder.getView(R.id.ivSelAudioItemSel).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.ivSelAudioItemSel).setVisibility(View.GONE);
            }
        }
    }


}
